package featuremodel.predication;

import skyblue.Method;
import skyblue.SkyBlueDef;
import skyblue.Variable;

import featuremodel.FeatureGroup;
import featuremodel.FeatureRep;

public class CompositeAllTrue extends Method {
	private FeatureGroup featureGroup;

	public CompositeAllTrue(FeatureGroup featureGroup) {

		this.featureGroup = featureGroup;
		getOutputs().addAll(featureGroup.getVariables());

	}

	public void setTobeMethodType() {
		for (int i = 0; i < featureGroup.getVariables().size(); i++) {
			featureGroup.getVariables().get(i).setTobemethodtype(
					SkyBlueDef.METHOD_TYPE_BIND);
		}
	}

	public void clearTobeMethodType() {
		for (int i = 0; i < featureGroup.getVariables().size(); i++) {
			featureGroup.getVariables().get(i).setTobemethodtype(null);
		}
	}

	public void setTobeMethodType2() {
		for (int i = 0; i < featureGroup.getVariables().size(); i++) {
			featureGroup.getVariables().get(i).setTobeMethodType2(
					SkyBlueDef.METHOD_TYPE_BIND);
		}

	}

	public void clearTobeMethodType2() {
		for (int i = 0; i < featureGroup.getVariables().size(); i++) {
			featureGroup.getVariables().get(i).setTobeMethodType2(null);
		}
	}

	public void execute() {
		Variable feature;
		FeatureRep fp;
		for (int i = 0; i < featureGroup.getVariables().size(); i++) {
			feature = featureGroup.getVariables().get(i);
			fp = (FeatureRep) feature.getValue().getValuerep();
			fp.setBindState(SkyBlueDef.VARIABLE_BIND);
			feature.setMethodtype(SkyBlueDef.METHOD_TYPE_BIND);
			feature.setTobemethodtype(null);
		}

	}

}
